/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.openbrew.openbrewrf;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.criteria.Fetch;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "CustomerGroup")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CustomerGroup.findAll", query = "SELECT c FROM CustomerGroup c"),
    @NamedQuery(name = "CustomerGroup.findByCustomerGroupID", query = "SELECT c FROM CustomerGroup c WHERE c.customerGroupID = :customerGroupID"),
    @NamedQuery(name = "CustomerGroup.findByCustomerGroupDescription", query = "SELECT c FROM CustomerGroup c WHERE c.customerGroupDescription = :customerGroupDescription"),
    @NamedQuery(name = "CustomerGroup.findByCustomerGroupNotes", query = "SELECT c FROM CustomerGroup c WHERE c.customerGroupNotes = :customerGroupNotes"),
    @NamedQuery(name = "CustomerGroup.findByCustomerGroupAuto", query = "SELECT c FROM CustomerGroup c WHERE c.customerGroupAuto = :customerGroupAuto"),
    @NamedQuery(name = "CustomerGroup.findByCustomerGroupObsolete", query = "SELECT c FROM CustomerGroup c WHERE c.customerGroupObsolete = :customerGroupObsolete")})
public class CustomerGroup implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "CustomerGroupID")
    private Integer customerGroupID;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 250)
    @Column(name = "CustomerGroupDescription")
    private String customerGroupDescription;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 250)
    @Column(name = "CustomerGroupNotes")
    private String customerGroupNotes;
    @Basic(optional = false)
    @NotNull
    @Column(name = "CustomerGroupAuto")
    private boolean customerGroupAuto;
    @Basic(optional = false)
    @NotNull
    @Column(name = "CustomerGroupObsolete")
    private boolean customerGroupObsolete;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "allocationCustGroupID")
    private Collection<Allocation> allocationCollection;
    @OneToMany(mappedBy = "custGroupID")
    private Collection<Customer> customerCollection;

    public CustomerGroup() {
    }

    public CustomerGroup(Integer customerGroupID) {
        this.customerGroupID = customerGroupID;
    }

    public CustomerGroup(Integer customerGroupID, String customerGroupDescription, String customerGroupNotes, boolean customerGroupAuto, boolean customerGroupObsolete) {
        this.customerGroupID = customerGroupID;
        this.customerGroupDescription = customerGroupDescription;
        this.customerGroupNotes = customerGroupNotes;
        this.customerGroupAuto = customerGroupAuto;
        this.customerGroupObsolete = customerGroupObsolete;
    }

    public Integer getCustomerGroupID() {
        return customerGroupID;
    }

    public void setCustomerGroupID(Integer customerGroupID) {
        this.customerGroupID = customerGroupID;
    }

    public String getCustomerGroupDescription() {
        return customerGroupDescription;
    }

    public void setCustomerGroupDescription(String customerGroupDescription) {
        this.customerGroupDescription = customerGroupDescription;
    }

    public String getCustomerGroupNotes() {
        return customerGroupNotes;
    }

    public void setCustomerGroupNotes(String customerGroupNotes) {
        this.customerGroupNotes = customerGroupNotes;
    }

    public boolean getCustomerGroupAuto() {
        return customerGroupAuto;
    }

    public void setCustomerGroupAuto(boolean customerGroupAuto) {
        this.customerGroupAuto = customerGroupAuto;
    }

    public boolean getCustomerGroupObsolete() {
        return customerGroupObsolete;
    }

    public void setCustomerGroupObsolete(boolean customerGroupObsolete) {
        this.customerGroupObsolete = customerGroupObsolete;
    }

    @XmlTransient
    public Collection<Allocation> getAllocationCollection() {
        return allocationCollection;
    }

    public void setAllocationCollection(Collection<Allocation> allocationCollection) {
        this.allocationCollection = allocationCollection;
    }

    @XmlTransient
    public Collection<Customer> getCustomerCollection() {
        return customerCollection;
    }

    public void setCustomerCollection(Collection<Customer> customerCollection) {
        this.customerCollection = customerCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (customerGroupID != null ? customerGroupID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CustomerGroup)) {
            return false;
        }
        CustomerGroup other = (CustomerGroup) object;
        if ((this.customerGroupID == null && other.customerGroupID != null) || (this.customerGroupID != null && !this.customerGroupID.equals(other.customerGroupID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.CustomerGroup[ customerGroupID=" + customerGroupID + " ]";
    }
    
}
